<!--
 * @Author: 王明明834578987 10266004+wang-mingming-834578987@user.noreply.gitee.com
 * @Date: 2024-08-29 10:59:23
 * @LastEditors: 王明明834578987 10266004+wang-mingming-834578987@user.noreply.gitee.com
 * @LastEditTime: 2024-09-27 15:54:59
 * @FilePath: \ft-apply-admin\src\views\applicationDetails\RTComponent\CVTache\CVWatting.vue
 * @Description: 
-->
<template>
  <div id="cv-watting">
    <RTHeader label="简历环节" :statusInfo="statusInfo"></RTHeader>
    <a-checkbox v-model:checked="isSendEmail">发送短信通知</a-checkbox>
    <a-textarea v-model:value="reason" placeholder="请填写原因" :autoSize="{ minRows: 4, maxRows: 4 }" />
    <div class="btns">
      <Button v-auth="'resumesProgress'" color="success" @click="pass">通过</Button>
      <Button v-auth="'resumesEliminate'" color="error" @click="dieOut">淘汰</Button>
      <Button v-auth="'offlineInterviewDetail'" color="#6C7DA8" @click="offline">线下到面</Button>
    </div>
  </div>
</template>

<script setup lang='ts'>
import { ref } from "vue";
import RTHeader from '../RTHeader.vue';
import { Button } from "@/components/Button";
import { resumeProgress, offlineInterviewType } from "@/api/application-details/index.ts";
const props = defineProps(['process'])
import { comStores } from '@/store/common/comStore';
import { message } from "ant-design-vue";
const store = comStores()
const statusInfo = ref({
  status: "待筛选"
})
const { userName } = store.userInFor
const reason = ref<string>("");
const isSendEmail =ref<boolean>(true)
const pass = async () => {
  const { resumeId, processId } =store.currentResume  //props.process;
  const data = await resumeProgress({
    resumeId,
    processId: processId,
    result: "通过",
    reason: reason.value,
    operator: userName,
    isSend:isSendEmail.value
  });
  console.log(data)
  if (data && data.code == '10000') {
    message.success('更新成功')
    await store.getResumeInfo(resumeId)
  } else {
    message.error(data.msg)
  }
}

const dieOut = async () => {
  const { resumeId, processId } = store.currentResume 
  const data = await resumeProgress({
    resumeId,
    processId: processId,
    result: "淘汰",
    reason: reason.value,
    operator: userName,
    isSend:isSendEmail.value
  })
  if (data && data.code == '10000') {
    message.success('更新成功')
    await store.getResumeInfo(resumeId)
  } else {
    message.error(data.msg)
  }
}

const offline = async () => {
  const { resumeId, processId } = store.currentResume;
  const { userName } = store.userInFor
  console.log('offline');
  let param = {
    resumeId: resumeId,
    operator: userName,
  }
  const data = await offlineInterviewType(param)
  if (data && data.code == '10000') {
    message.success('操作成功');
    await store.getResumeInfo(resumeId)
  } else {
    message.error(data.msg)
  }
}
</script>
<style lang="less" scoped>
.btns {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
</style>